package com.zz.inventory.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;

import java.io.FileWriter;
import java.io.IOException;


/**
 * 支付宝的APPID
 * 应用私钥
 * 支付宝公钥
 * 支付宝通知本地的接口完整地址
 *
 */
@Configuration
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AlipayConfig {


    // 收款账号既是,APPID对应支付宝账号,发起请求的应用ID
    public String app_id = "9021000150624444";

    // 商户私钥，PKCS8格式RSA2私钥
    public String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfDJlQiff68/FePAxePwRqattcXiy3LDZYCep9q6kFez8ss6FvmlpoIwERZzzfdamdF51cVcIzWbi5Xrr65YFJCYzsTZjNEogIDr8FH9oVTjage9TQ45NClUzJllWluimNye2xVcmWHV1kB6HKGrfLZAt113966sRuTSat5NuEugYmZJHVcIUkORbj6XX4Tvm98y8X114IJMlCPPuXPVjPTsykzDiiarAZ1YsatWlLPRNfGhsrqE1ip3UJxrx4jkLE3VknkOacmd9bKfDBgqSCXnbD5jCGP23mvFsi3BeryseInKZWR4p+bT4b4R6FavqCDQzmoh5fkW4/HXolB0sxAgMBAAECggEAHFLrDquzTK6aolSBQ1tnluf2rqlavzgRaXZCmySx0fcT1gsbSbusM/Vf4FCJR6Y1kXM+I85l6i0lN2XGWJ38exxHS2G6P3L4ZK7zl58HgFnQYp4K1TRh6i6aYR/zmrLfaY+3U6haYPBTzFeLmWlOp9rmK5M38ZTTbG0y4S7rZORP69kONF30ljajHx42h0V7yRsCm3nxodt+qzTWO8k4cRz4lW8rBTBQGNC1YyWvTO672UV4zi7uw1lN10aGrUNgYaUQAAKjMu5GO/kLToTg5d0QAS6T3fj5DPUPL6WzulwXtdglszexiTQOkDwSko6GtVkafRgYNFtC+isAH7SnPQKBgQDV+P2McDvsVBGuhi80bk4MwLA2UDUTJgauaQ+ft2pXhcJ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Z/y6R+c9v78rwrw0+cEMg430QUE/T70DJ3dvCymJLCPp/1ZT7B0xhltr/wlTgjKXEWfA4wKvjAPtk5yqma5HqTXSQkStOGKxib1Q2i0707XbHYTTxcReZeOlfHEnM7te5O8mf/JhLKULNsZXJavDz/SnovMRnUShmg+8OaV/tbbQyBwIDAQAB";

    // 服务器异步通知页面路径 ，必须外网可以正常访问
    public String notify_url = "http://lennon.natapp1.cc/platform/alipay/notify";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，必须外网可以正常访问
    public static String return_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
